﻿
Public Class setTimeout
    Public Const functionName As String = "sto"

    Public Shared Sub register(ByVal inlineScript As inlineScript)
        assert(Not inlineScript Is Nothing, "inlineScript is nothing.")
        inlineScript.addscript("setTimeout", "function " + functionName + "(c,m,l){return setTimeout(c,m,l);}")
    End Sub

    Public Shared Function invoke(ByVal inlineScript As inlineScript, _
                                  ByVal code As String, ByVal ms As Int64, _
                                  Optional ByVal language As String = Nothing, _
                                  Optional ByRef actionTarget As String = Nothing) As String
        If Not inlineScript Is Nothing Then
            register(inlineScript)
        End If

        actionTarget += functionName + "(" + code + "," + Convert.ToString(ms)
        If Not isemptystring(language) Then
            actionTarget += "," + language
        End If
        actionTarget += ")"
        Return actionTarget
    End Function

    Public Shared Function invoke(ByVal page As xhtmlpage, _
                                  ByVal code As String, ByVal ms As Int64, _
                                  Optional ByVal language As String = Nothing, _
                                  Optional ByRef actionTarget As String = Nothing) As String
        assert(Not page Is Nothing, "page is nothing.")
        Return invoke(page.inlineScript(), code, ms, language, actionTarget)
    End Function
End Class

Public Class clearTimeout
    Public Const functionName As String = "wct"

    Public Shared Sub register(ByVal inlineScript As inlineScript)
        assert(Not inlineScript Is Nothing, "inlineScript is nothing.")
        inlineScript.addscript("clearTimeout", "function " + functionName + "(n){window.clearTimeout(n);}")
    End Sub

    Public Shared Function invoke(ByVal inlineScript As inlineScript, ByVal name As String, _
                                  Optional ByRef actionTarget As String = Nothing) As String
        If Not inlineScript Is Nothing Then
            register(inlineScript)
        End If

        actionTarget += functionName + "(" + name + ")"
        Return actionTarget
    End Function
End Class